{include $data.pathToError}
<script type="text/javascript">
    {literal}
        
    function showSecondUser(type){
        var both = "{/literal}{$data.bothMovesOfCash}{literal}";
        if (type==both){
            $("#secondUser").show();
        } else {
            $("#secondUser").hide();
        }
    }
        
    $(document).ready(function() {
        $(".float").change(function() {
            makeFloat(".float");
        });
        $("#date").datepicker({ 
            dateFormat: "dd/mm/yy",
            firstDay: 1     
        });
    });
    {/literal}
</script>
<h2 class="pageTitle">Add entry into cash</h2>
<form class="adding" action="{$data.root}?input=add_entry" method="post" onsubmit="return checkAdd_entry(
                                                                    $('#date').val(), 
                                                                    $('#amount').val(),
                                                                    $('#description').val()
                                                                                   )">
    <table class="tableForm">
        <tr>
            <td>
                <label for="user">User<span class="red">*</span> </label>
            </td>
            <td>
                <select name="entry[user]" id="user" size="1">
                    {foreach $data.recipients as $key => $user}
                        <option {if $user.users_id == $smarty.session.user.user_id}selected="selected"{/if} value="{$user.users_id}">{$user.surname}, {$user.name}</option>
                    {/foreach}
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="date">Date <span class="red">*</span> </label>
            </td>
            <td>
                <input name="entry[date]" id="date" type="text" value="{$smarty.now|date_format:"%d/%m/%Y"}" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="amount">Amount<span class="red">*</span> </label>
            </td>
            <td>
                <input name="entry[amount]" id="amount" type="text" class="float" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="moveType">Type of move<span class="red">*</span> </label>
            </td>
            <td>
                <select name="entry[moveType]" id="moveType" size="1" onchange="showSecondUser(this.value)">
                    {foreach $data.cash_types as $key => $type}
                        <option {if $type.Id == 1 }selected="selected"{/if} value="{$type.Id}">{$type.TypPohybu}</option>
                    {/foreach}
                </select>
            </td>
        </tr>
        <tr id="secondUser" style="display: none">
            <td>
                <label for="recipient">Recipient<span class="red"></span> </label>
            </td>
            <td>
                <select name="entry[recipient]" id="recipient" size="1">
                    {foreach $data.recipients as $key => $user}
                        <option value="{$user.users_id}">{$user.surname}, {$user.name}</option>
                    {/foreach}
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="description">Description <span class="red">*</span></label>
            </td>
            <td>
                <textarea cols="30" rows="5" name="entry[description]" id="description"></textarea>
            </td>
        </tr>
        {if $smarty.session.user.user_type_id==$smarty.const.USER_TYPE_ADMIN}
        <tr>
            <td>
                <label for="s">S</label>
            </td>
            <td>
                <input name="entry[s]" id="s" type="checkbox" value="1" />
            </td>
        </tr>
        {/if}
        <tr class="submitRow">
            <td>
                <input name="action" value="add_entry" type="hidden" />
            </td>
            <td>
                <input type="submit" value="Add entry" name="add_entry" /> &nbsp; 
                <span class="red">* Required</span>
            </td>
            <td></td>
        </tr>
    </table>
</form>